﻿using System.Collections.Generic;
using System.Linq;

namespace MvcCms.Data.Code
{
    /// <summary>
    /// We are moving away from specific implementation at the base repository level and moving this out to data.service projects that can
    /// provide different implementations as needed.  This prevents the problem of too many services using the same repository methods
    /// and having different or slightly different needs.  Data.Service projects can now be made to hand off requests to the Business Service
    /// layer which will finalize the data request and do tolist if needed.  All methods at the repository level should be as generic as possible.
    ///
    /// This is being started here in the AccountRepository class, we will leave the EntityAccountRepository class untill all requesting services
    /// have been converted to use a Data.Service project instead of the repository.
    /// </summary>
    public class AccountRepository : IAccountRepository
    {
        #region Constructors
        private readonly MvcCmsEntities _entities;
        public AccountRepository(IEntitiesProvider entitiesProvider)
        {
            _entities = entitiesProvider.GetEntityContext();
        }
        #endregion

        public IEnumerable<User> ListUsers()
        {
            return (from u in _entities.UserSet
                    select u);
        }
    }
}
